<template>
  <HomePannel ref="target" title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
    <template #right>
      <XtxMore path="/" />
    </template>
    <HomeCommonList :list="newData" />
    <!-- 商品列表
    <ul ref="pannel" class="goods-list">
      <li v-for="item in newData" :key="item.id">
        <RouterLink to="/">
          <img :src="item.picture" alt="" />
          <p class="name">{{ item.name }}</p>
          <p class="price">&yen;{{ item.price }}</p>
        </RouterLink>
      </li>
    </ul> -->
  </HomePannel>
</template>

<script>
import HomePannel from './home-panel.vue'
import { findNew } from '@/api/home'
import { ref } from 'vue'
// 导入商品列表组件
import HomeCommonList from './home-common-list.vue'
import { useObserve } from '@/hook'

export default {
  components: {
    HomePannel,
    HomeCommonList
  },
  setup () {
    const newData = ref([])
    async function getNew () {
      const { result } = await findNew()
      console.log(result)
      newData.value = result
    }
    const { target } = useObserve(getNew)
    return { newData, target }
  }
}
</script>

<style lang="less" scoped>
</style>
